<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core">

<p:panel header="CONTRATOS" style="width:1500px">
	<h:form id="formContratos">
		<h:panelGrid columns="9" cellpadding="5">
                Nome:
                <p:inputText size="30"
				value="#{contratoBean.contrato.projeto.nome}" />
                Categoria:
                <p:selectOneMenu id="categoria"
				value="#{contratoBean.contrato.projeto.categoria}"
				converter="categoriaConverter">
				<f:selectItem itemLabel="-- Selecione --" />
				<f:selectItems value="#{categoriaBean.categorias}" var="categoria"
					itemValue="#{categoria}" itemLabel="#{categoria.nome}" />

			</p:selectOneMenu> 
                Ano:
                <p:selectOneMenu id="ano" value="#{contratoBean.ano}">
				<f:selectItem itemLabel="-- Selecione --" />
				<f:selectItems value="#{contratoBean.anos}" var="ano"
					itemValue="#{ano}" itemLabel="#{ano}" />
			</p:selectOneMenu> 
                Em aberto
                <p:selectBooleanCheckbox>

			</p:selectBooleanCheckbox>
			<p:commandButton value="Pesquisar" ajax="false" 
				action="#{contratoBean.pesquisar}" />
		</h:panelGrid>
		<br />
		<br />
		<p:dataTable id="gridContratos" var="contrato"
			value="#{contratoBean.contratos}"
			emptyMessage="Nenhum registro encontrado" paginator="true" rows="10"
			paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
			rowKey="#{contrato.id}"
			selection="#{contratoBean.contratoConsultado}" selectionMode="single">
			<p:ajax event="rowSelect" update="@form" />
			<p:column headerText="Projeto">
				<h:outputText value="#{contrato.projeto.nome}" />
			</p:column>
			<p:column headerText="Valor">
				<h:outputText value="#{contrato.valor}" />
			</p:column>
			<p:column headerText="Freelancer">
				<h:outputText value="#{contrato.freelancer.nome}" />
			</p:column>

			<p:column headerText="Duração">
				<h:outputText value="#{contrato.projeto.duracao}" />

			</p:column>

			<f:facet name="footer">
				<h:panelGroup id="botoes">
					<!-- Panel de Botoes do Dono de Projeto -->
					<h:panelGroup id="panelDonoProjeto"
						rendered="${usuarioSessaoBean.perfil == 'DP'}">
						<p:button id="btVisualizarFree" icon="ui-icon-search"
							value="Visualizar Freelancer" outcome="/projeto/consultarProjeto">
							<f:param name="contrato"
								value="#{contratoBean.contratoConsultado.id}" />
						</p:button>
						<p:commandButton
							rendered="#{contratoBean.contratoConsultado.aberto}"
							id="btConcluir" value="Concluir Contrato"
							onclick="fecharContratoDialog.show()" />





					</h:panelGroup>
					<!-- Panel de Botoes do Freelancer -->
					<h:panelGroup rendered="${usuarioSessaoBean.perfil == 'FREE'}">
						<p:button id="btEfetuarLances" value="Efetuar Lance"
							outcome="/lance/exibirLances">
							<f:param name="contrato"
								value="#{contratoBean.contratoConsultado.id}" />
						</p:button>
					</h:panelGroup>
				</h:panelGroup>
			</f:facet>


		</p:dataTable>

		




	</h:form>
</p:panel>


</html>

